﻿using Camera.Net;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
          MJpegStreamingServer server = new MJpegStreamingServer(8080);
          CameraCapture camera = new CameraCapture();
            
        private void Form1_Load(object sender, EventArgs e)
        {
            camera.OnFrameChanged += camera_OnFrameChanged;
        }

        void camera_OnFrameChanged(object sender, byte[] buffer)
        {
            if (buffer != null && buffer.Length > 0)
                server.Write(buffer);
        }

        private void button1_Click(object sender, EventArgs e)
        {

            server.Start();
            camera.Open("rtsp://admin:admin@192.168.0.108:554");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            server.Stop();
            camera.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            
        }
    }
}
